package com.xuan.bigdog.lib.chat.view;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ListView;

import com.xuan.bigdog.R;
import com.xuan.bigdog.lib.widgets.BaseLayout;
import com.xuan.bigdog.lib.widgets.title.DGTitleLayout;

/**
 * 会话聊天布局
 * 
 * @author xuan
 */
public class DGConversationView extends BaseLayout {
	private final Activity activity;
	private DGTitleLayout titleLayout;// 标题栏
	private ListView listView;// 消息内容listView
	private DGConversationBottomBarView bottomBarView;// 底部操作栏

	public DGConversationView(Context context) {
		super(context);
		activity = (Activity) context;
	}

	public DGConversationView(Context context, AttributeSet attrs) {
		super(context, attrs);
		activity = (Activity) context;
	}

	@Override
	protected void dgInit() {
		loadView();
		initWidgits();
	}

	/** Load view */
	private void loadView() {
		inflate(getContext(), R.layout.dg_chat_conversation, this);
		bottomBarView = (DGConversationBottomBarView) findViewById(R.id.bottomBarView);
		titleLayout = (DGTitleLayout) findViewById(R.id.titleLayout);
		listView = (ListView) findViewById(R.id.listView);
	}

	/** Init view */
	private void initWidgits() {
		// 标题
		titleLayout.initTitle("聊天", new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				activity.finish();
			}
		});
	}

	public DGTitleLayout getTitleLayout() {
		return titleLayout;
	}

	public ListView getListView() {
		return listView;
	}

	public DGConversationBottomBarView getBottomBarView() {
		return bottomBarView;
	}

}
